package com.yc.navy.goods.service.lmpl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yc.navy.goods.bean.BalanceInfo;
import com.yc.navy.goods.dto.BalanceInfoDTO;
import com.yc.navy.goods.dto.ProductInfoDTO;
import com.yc.navy.goods.mapper.IBalanceInfoMapper;
import com.yc.navy.goods.service.IBalanceInfoService;
import com.yc.navy.goods.util.StringUtil;

@Service
public class BalanceInfoServicelmpl implements IBalanceInfoService{
	@Autowired
	private IBalanceInfoMapper BalanceInfoMapper;

	@Override
	public List<BalanceInfo> find(int pid) {
		if(StringUtil.checkNull(pid)) {
			return null;
		}
		return BalanceInfoMapper.find(pid);
	}

	@Override
	public int findbid() {
		return BalanceInfoMapper.findbid();
	}

	/*@Override
	public int updateNum(OrderItemInfoDTOO orderitem) {
		return BalanceInfoMapper.updateNum(orderitem);
	}*/

	@Override
	public List<BalanceInfo> findList() {
		return BalanceInfoMapper.findList();
	}

	@Override
	public int addNum(BalanceInfo balance) {
		if(StringUtil.checkNull(balance.getBnum().toString(),balance.getBid().toString())) {
			return -1;
		}
		return BalanceInfoMapper.addNum(balance);
	}

	@Override
	public int addNums(BalanceInfo balance) {
		if(StringUtil.checkNull(balance.getBnum().toString(),balance.getBcolor(),balance.getBsize(),String.valueOf(balance.getPid()))) {
			return -1;
		}
		return BalanceInfoMapper.addNums(balance);
	}

	@Override
	public int add(BalanceInfo balance) {
		if(StringUtil.checkNull(balance.getBnum().toString(),balance.getBcolor(),balance.getBsize(),String.valueOf(balance.getPid()))) {
			return -1;
		}
		return BalanceInfoMapper.add(balance);
	}
	
	@Override
	public int updateNum(BalanceInfoDTO balanceInfo) {
		return BalanceInfoMapper.updateNum(balanceInfo);
	}

	@Override
	public Integer findBalanceByPid(ProductInfoDTO product) {
		if(StringUtil.checkNull(String.valueOf(product.getPid()),String.valueOf(product.getBcolor()),String.valueOf(product.getBsize()))) {
			return -1;
		}
		return BalanceInfoMapper.findBalanceByPid(product);
	}

	@Override
	public Integer updateBalance(ProductInfoDTO product) {
		if(StringUtil.checkNull(String.valueOf(product.getBsize()),String.valueOf(product.getBcolor()),String.valueOf(product.getBnum()),String.valueOf(product.getBid()))) {
			return -1;
		}
		return BalanceInfoMapper.updateBalance(product);
	}

	@Override
	public Integer delbalanceBnum(Integer bid) {
		return BalanceInfoMapper.delbalanceBnum(bid);
	}

}
